#import "YYText.h"
#import "dfhgwhruebvhrheyluggagerecorder.h"
#import "dfhgwhruebvhrheygarbageequator.h"
#import "dfhgwhruebvhrheybangorganismViewController.h"
#import "dfhgwhruebvhrheyengineeringroyal.h"
#import "dfhgwhruebvhrheyreciprocaltransportViewController.h"
@interface dfhgwhruebvhrheyreciprocaltransportViewController ()
@property (weak, nonatomic) IBOutlet YYLabel *tipsText;
@property (weak, nonatomic) IBOutlet UILabel *amountTextLabel;
@property (weak, nonatomic) IBOutlet UILabel *repaymentCodeLabel;
@end
@implementation dfhgwhruebvhrheyreciprocaltransportViewController
- (void)viewDidLoad {
    [super viewDidLoad];
	[self loadUI];
}
- (void)loadUI {
	self.amountTextLabel.text = self.amountString;
	NSMutableAttributedString *tipsAttribute = [[NSMutableAttributedString alloc] initWithString:@"Tips:\n1. We don't accept other unoffical repayment channels , please be aware being fraud when someone asking you to pay other channels. if there is a loss , you have to bear it yourself.\n2. We highly recommended that you use GCash for repayment , which is convenient , fast and safe."];
	NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
	style.lineSpacing = 5;
	[tipsAttribute addAttributes:@{
		NSParagraphStyleAttributeName: style,
		NSFontAttributeName: [UIFont regular:13],
		NSForegroundColorAttributeName: @"#AAAAAA".dhgfywegwygeydwlearneddesignate
	} range:NSMakeRange(0, tipsAttribute.length)];
	self.tipsText.numberOfLines = 0;
	self.tipsText.attributedText = tipsAttribute;
}
- (void)bindData:(dfhgwhruebvhrheyengineeringroyal *)model {
	self.repaymentCodeLabel.text = model.contract_number;
}
- (void)getRepaymentCode:(void(^)(dfhgwhruebvhrheyengineeringroyal *code))result {
	NSMutableDictionary *params = [NSMutableDictionary dictionary];
	params[@"gid"] = self.repayment.ad_id;
	params[@"type"] = @(self.type);
	if(self.type == 1) {
		params[@"cop_id"] = self.coupon_id;
	}
	__weak typeof(self) weakSelf = self;
	[[dfhgwhruebvhrheyluggagerecorder shareInstance] dhgfywegwygeydwbarrierawait:dhgfywegwygeydwawaitlamb path:repaymentCodeApi isEncrypt:YES withParams:params success:^(NSURLSessionDataTask * _Nonnull task, NSString * _Nonnull json) {
		__strong typeof(weakSelf) strongSelf = weakSelf;
		dfhgwhruebvhrheyengineeringroyal *model = [dfhgwhruebvhrheyengineeringroyal yy_modelWithJSON:json];
		if (model.code == 200) {
			[strongSelf bindData:model];
		}else {
			[dfhgwhruebvhrheyoptionsaving.keyWindow show:model.error];
		}
		if (result) {
			result(model);
		}
	} failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
		if (result) {
			result(nil);
		}
	}];
}
- (IBAction)copyAction {
	NSCharacterSet *charSet = [NSCharacterSet whitespaceCharacterSet];
	NSString *codeString = self.repaymentCodeLabel.text;
	codeString = [[codeString componentsSeparatedByCharactersInSet:charSet] componentsJoinedByString:@""];
	UIPasteboard *paste = [UIPasteboard generalPasteboard];
	paste.string = codeString;
	[dfhgwhruebvhrheyoptionsaving.keyWindow show:@"Copy Success!"];
}
- (IBAction)serviceAction:(UITapGestureRecognizer *)sender {
	dfhgwhruebvhrheybangorganismViewController *webVC = [[dfhgwhruebvhrheybangorganismViewController alloc] init];
	webVC.isShowBottomView = NO;
	webVC.hidesBottomBarWhenPushed = YES;
	if (sender.view.tag == 100) {
		[webVC loadURLString:howToRepayH5];
		webVC.navigationItem.title = @"How To Repayment";
	}else {
		[webVC loadURLString:serviceH5];
		webVC.navigationItem.title = @"Assistance";
	}
	[self.navigationController pushViewController:webVC animated:YES];
}
@end
